﻿using Microsoft.Commerce.Contracts;

namespace MusicWorks.Service.DataContracts
{
    public class Category : HierarchicalCatalogEntity
    {
        /// <summary>
        /// defines the model name for this commerce entity
        /// </summary>
        public new const string ModelNameDefinition = "Category";

        public Category() : base(ModelNameDefinition)
        {
        }

        public Category(CommerceEntity commerceEntity)
            : base(commerceEntity)
        {
        }

        public static implicit operator Category(CommerceEntity commerceEntity)
        {
            return new Category(commerceEntity);
        }

        public CommerceRelationshipList ChildCategories
        {
            get { return _commerceEntity.GetPropertyValue(RelationshipName.ChildCategories) as CommerceRelationshipList; }
            set { _commerceEntity.SetPropertyValue(RelationshipName.ChildCategories, value); }
        }

        public CommerceRelationshipList CategoryHierarchy
        {
            get { return CommerceEntity.GetPropertyValue(RelationshipName.CategoryHierarchy) as CommerceRelationshipList; }

            set { CommerceEntity.SetPropertyValue(RelationshipName.CategoryHierarchy, value); }
        }

        public CommerceRelationshipList ChildProducts
        {
            get { return _commerceEntity.GetPropertyValue(RelationshipName.ChildProducts) as CommerceRelationshipList; }
            set { _commerceEntity.SetPropertyValue(RelationshipName.ChildProducts, value); }
        }

        public new class RelationshipName
        {
            public const string ChildCategories = "ChildCategories";
            public const string ChildProducts = "ChildProducts";
            public const string CategoryHierarchy = "CategoryHierarchy";
        }
    }
}